package com.lngsyz.ywtb.biz.service;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.lngsyz.ywtb.entity.source1.SystemCustom;
import com.lngsyz.ywtb.mapper.source1.SystemCustomMapper;

import net.logstash.logback.encoder.org.apache.commons.lang.StringUtils;

@Service
public class SystemCustomService {
    
	@Autowired
	SystemCustomMapper systemCustomMapper;
	
    public List<SystemCustom> findByBusinessLicense(String businessLicense){
    	Map<String, Object> param = new HashMap<String, Object>();
    	if(StringUtils.isNotBlank(businessLicense)) {
    		param.put("businesslicense", businessLicense);
    		List<SystemCustom> lists = systemCustomMapper.findByCondition(param);
    		return lists;
    	} else {
    		return new ArrayList<SystemCustom>(); 
    	}
    }
    
    public SystemCustom findById(String id) {
    	if(StringUtils.isNotBlank(id)) {
    		return systemCustomMapper.findById(id);
    	} else {
    		return null;
    	}
    }
    
    public SystemCustom findByBusinessLicenseForOne(String businessLicense) {
    	List<SystemCustom> systemCustoms = findByBusinessLicense(businessLicense);
    	if(systemCustoms != null && systemCustoms.size() > 0) {
    		return systemCustoms.get(0);
    	} else {
    		return null;
    	}
    }
}
